package com.adan.base.model;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @version: 1.0
 * @Author: adan
 * @description:
 * @date: 2023-05-30 23:58
 */
@Data
public class PageResult<T> implements Serializable {

    // 数据列表
    private List<T> items;
    // 总记录数
    private long counts;
    // 当前页码
    private long page;
    // 每页记录数
    private long pageSize;

    public PageResult() {
    }

    public PageResult(List<T> items, long counts, long page, long pageSize) {
        this.items = items;
        this.counts = counts;
        this.page = page;
        this.pageSize = pageSize;
    }
    public PageResult(Page<T> pageResult) {
        this.counts = pageResult.getTotal();
        this.items = pageResult.getRecords();
        this.page = pageResult.getCurrent();
        this.pageSize = pageResult.getSize();

    }
}
